home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / c / gcc222-2.lha / gcc_include / signal.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-08  |  3.0 KB  |  86 lines

  1. /*    signal handling for ansic.library        */
  2. /*    (c)Copyright 1992 Davide Pasetto         */
  3.  
  4. #ifndef    _SIGNAL_H
  5. #define _SIGNAL_H
  6.  
  7. #include    <dos/dos.h>
  8.  
  9. /* This header file contains definitions needed by the signal function    */
  10. /* NSIG supposedly defines the number of signals actually recognized.    */
  11.  
  12. #define    NSIG    25
  13.  
  14. /* The following symbols are the supported signals */
  15.  
  16. #define    SIGHUP    1    /* hangup */
  17. #define    SIGINT    2    /* interrupt */
  18. #define    SIGQUIT    3    /* quit */
  19. #define SIGILL    4    /* illegal istruction (not reset when cought) */
  20. #define    SIGTRAP    5    /* trace trap (not reset when cought) */
  21. #define SIGIOT    6    /* IOT istruction */
  22. #define SIGEMT    7    /* EMT istruction */
  23. #define SIGFPE    8    /* floating point exception */
  24. #define SIGKILL    9    /* kill cannot be caught or ignored */
  25. #define SIGBUS    10    /* bus error */
  26. #define SIGSEGV    11    /* segment violation */
  27. #define SIGSYS    12    /* bad argument to system call */
  28. #define SIGPIPE    13    /* write to a pipe with no one reading */
  29. #define    SIGALRM 14    /* alarm signal */
  30. #define SIGTERM    15    /* software termination signal */
  31.                     /* this is unassigned */
  32. #define SIGSTOP    17    /* stop (cannot be caught or ignored) */
  33. #define    SIGTSTP    18    /* stop from keyboard */
  34. #define SIGCONT    19    /* continue after stop */
  35. #define SIGCHLD    20    /* child status changed */
  36. #define SIGTTIN    21    /* background read attempted from control terminal */
  37. #define SIGTTOU    22    /* background write attempted to control terminal */
  38. #define SIGTINT    23    /* input record avaiable at control terminal */
  39. #define SIGXCPU    24    /* cpu time limit exceded */
  40. #define SIGXFSZ    25    /* file size limit exceded */
  41.  
  42. /* The following symbols are the standard actions supported for each signal */
  43.  
  44. #define SIG_IGN    (void (*)(int))0    /* ignore the signal */
  45. #define SIG_DFL    (void (*)(int))1    /* default action for that signal */
  46.  
  47. /* Function declarations */
  48.  
  49. #ifdef    __cplusplus
  50. extern "C" {
  51. #endif
  52.  
  53. void    *signal(int, void *);
  54.  
  55. #ifdef    __cplusplus
  56. }
  57. #endif
  58.  
  59. /* These are needed for correct signal handling: a call to the operating system MUST be    */
  60. /* an atomic operation in the sense that no break signal must occour during that call.    */
  61. /* So we must use the below macro to start and end signal exception processing.        */
  62. /* If you want to use Amiga exception capability you must do an ATOMIC_ON to stop    */
  63. /* library internal exception processing; before exiting you must set everything back    */
  64. /* as at start.                                        */
  65. /* NOTE: Calling the c-library is safe becouse all routine know of this.        */
  66. /* NOTE: forbid woudn't help: the task will be breaked anycase.                */
  67. /* IMPORTANT NOTE: if you want to use exec exception processing you CANNOT call any    */
  68. /*                    library routine                    */
  69.  
  70. #define SIGNALSET    SIGBREAKF_CTRL_C|SIGBREAKF_CTRL_D|SIGBREAKF_CTRL_E|SIGBREAKF_CTRL_F
  71.  
  72. #ifdef    __cplusplus
  73. extern "C" {
  74. #endif
  75.  
  76. extern    long    _atomic_counter;
  77.  
  78. #ifdef    __cplusplus
  79. }
  80. #endif
  81.  
  82. #define ATOMIC_ON    { if(!_atomic_counter) SetExcept(0L,-1L); _atomic_counter++; }
  83. #define ATOMIC_OFF    { _atomic_counter--; if(_atomic_counter<=0) { SetExcept(SIGNALSET,-1L); _atomic_counter=0; } }
  84.  
  85. #endif    /* _SIGNAL_H */
  86.